import { defineStore } from 'pinia'

export const useUserInfoStore = defineStore('userInfo', {
    state() {
        return {
            user: {} , // 存储用户信息
            userId: ''     // 新增

        }
    },
    actions: {
        setUserInfo(user) {
            this.user = user
            this.userId = user.id ?? ''   // 把 id 单独拎出来

        },
        removeUserInfo() {
            this.user = {}
            this.userId = ''              // 顺手清掉

        }
    },
    persist: {
        enabled: true
    }
})
